from aiogram.types import ReplyKeyboardMarkup, KeyboardButton
# from config_data.config import current_family_hash
from datetime import datetime, timedelta

def generate_past_weeks():
    today_date = datetime.now()
    end_date = today_date
    weeks_list = []

    for i in range(4):
        start_date = end_date - timedelta(days=6)
        week_str = f"Неделя {i+1} ({start_date.strftime('%d.%m')} - {end_date.strftime('%d.%m')})"
        weeks_list.append(week_str)
        end_date = start_date - timedelta(days=1)
    
    return weeks_list

weeks = generate_past_weeks()
weeks.sort()


def just_keyboard() -> ReplyKeyboardMarkup:
    # if(current_family_hash['hash']):
    buttons = [
        ['Создать семью', 'Вступить в семью'],
        ['Покупка', 'Отчет'],
        ['Пригласить в семью', 'Выбрать семью'],
        ['Помощь']
    ]
    # else:
    #     buttons = [
    #         'Создать семью',
    #         'Вступить в семью',
    #     ]

    return ReplyKeyboardMarkup(
        keyboard=[[KeyboardButton(text=button) for button in line] for line in buttons],
        resize_keyboard=True
    )


def cancel_keyboard() -> ReplyKeyboardMarkup:
  return ReplyKeyboardMarkup(
        keyboard=[[KeyboardButton(text='Вернуться в меню')]],
        resize_keyboard=True
    )

def cancel_keyboard_report() -> ReplyKeyboardMarkup:
  return ReplyKeyboardMarkup(
        keyboard=[[KeyboardButton(text='Назад')], [KeyboardButton(text='Вернуться в меню')]],
        resize_keyboard=True
    )

def report_keyboard() -> ReplyKeyboardMarkup:
  return ReplyKeyboardMarkup(
        keyboard=[[KeyboardButton(text='Ваши покупки за неделю')], [KeyboardButton(text='Все расходы')]],
        resize_keyboard=True
    )


def report_keyboard() -> ReplyKeyboardMarkup:
  return ReplyKeyboardMarkup(
        keyboard=[
           [KeyboardButton(text='Ваши покупки за неделю')], [KeyboardButton(text='Все расходы')],
           [KeyboardButton(text='Вернуться в меню')]
           ],
        resize_keyboard=True
    )

def report_keyboard_weekly() -> ReplyKeyboardMarkup:
  return ReplyKeyboardMarkup(
      keyboard=[
         [KeyboardButton(text=weeks[0]), KeyboardButton(text=weeks[2])],
         [KeyboardButton(text=weeks[1]), KeyboardButton(text=weeks[3])],
        [KeyboardButton(text='Назад')],
        [ KeyboardButton(text='Вернуться в меню')]
        ],
        resize_keyboard=True
    )